﻿/// <reference path="../Jquery/jquery-1.7.1-vsdoc.js" />


if (typeof (Solution) == 'undefined') Solution = {};
Solution.Core = {
    Init: function () {

    },
    Overlay: function () {
        var overlay = $('#overlay');
        if (overlay.length <= 0) {
            var strOverlay = '<div id="overlay"><div class="overlay"  style="background:#000; position: absolute; top:0; left:0; width: 100%; height: 100%;  z-index: 1001; opacity: .4;"></div></div>';
            $('body').append(strOverlay);
        }
    },
    OverlayStr: function (str) {
        var strOverlay = '<div id="overlay"><div class="overlay" id="overlay" style="background:#000; position: absolute; top:0; left:0; width: 100%; height: 100%;  z-index: 101; opacity: .4;"></div>';
        strOverlay += '<div class="overlayPop" style="text-align:center;color:#fff;font-size:1.6em;padding:5px; position: absolute; top:5px; left:2px; min-height:30px; min-width:150px; z-index: 102">';
        strOverlay += str;
        strOverlay += '</div>';
        $('body').append(strOverlay);
    },
    RemoveOverlay: function () {
        $('#overlay').remove();
    },
    Wait: function (str) {
        var height = $(window).height();
        var width = $(window).width();
        var wait = '<div class="wait" id="wait" style="text-align:center;color:#fff;font-size:1.8em;padding:5px; position: absolute; top:' + (height / 2 - 100) + 'px; left:' + (width / 2 - 100) + 'px; min-height:30px; min-width:150px; z-index: 10003">';
        wait += str;
        wait += '</div>';
        $('body').append(wait);
    },
    RemoveWait: function () {
        setTimeout(function () { $('#wait').remove(); }, 1000);
    },
    WaitWithOverlay: function (str) {
        Solution.Core.Overlay();
        var height = $(window).height();
        var width = $(window).width();
        var wait = '<div class="wait" id="wait" style="text-align:center;color:#fff;font-size:1.8em;padding:5px; position: absolute; top:' + (height / 2 - 100) + 'px; left:' + (width / 2 - 100) + 'px; min-height:30px; min-width:150px; z-index: 10003">';
        wait += str;
        wait += '</div>';
        $('body').append(wait);
    },
    RemoveWaitThenOverlay: function () {
        setTimeout(function () { $('#wait').remove(); }, 500);
        setTimeout(function () { $('#overlay').remove(); }, 500);
        //  $('#overlay').remove();
    },
    FormatDatetime: function (cellvalue, options, rowObject) {
        var milli = cellvalue.replace(/\/Date\((-?\d+)\)\//, '$1');
        var date = new Date(parseInt(milli));
        var result = date.getDate() + '/' + date.getMonth() + '/' + date.getFullYear();
        return result;
    },
    FMDatetime: function (cellvalue, options, rowObject) {
        var date = new Date(cellvalue);    
        var result = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear();
        return result;
    },
    getParameterByName: function (name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regexS = "[\\?&]" + name + "=([^&#]*)";
        var regex = new RegExp(regexS);
        var results = regex.exec(window.location.search);
        if (results == null)
            return "";
        else
            return decodeURIComponent(results[1].replace(/\+/g, " "));
    },
    Redirect: function (url) {
        window.location.href = url;
    }


}